﻿using System.Data.SqlClient;
using Hyt.Passport.Persist;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using Hyt.Passport;
using System.Collections.Generic;
using Hyt.Core;
using Hyt.Passport.Service;

namespace Hyt.Test
{
    
    
    /// <summary>
    ///这是 PassportPersistServiceTest 的测试类，旨在
    ///包含所有 PassportPersistServiceTest 单元测试
    ///</summary>
    [TestClass()]
    public class PassportPersistServiceTest
    {


        /// <summary>
        ///Add 的测试
        ///</summary>
        public void AddTestHelper<T>()
            where T : class
        {
            //PassportPersistService target = new PassportPersistService(); // TODO: 初始化为适当的值
            //Administrator model =target.GetQuery<Administrator>().First();
            ////model.Name = "xxx3";
            ////model.UserName = "eee";
            ////model.Password = "dfsd";
            ////model.Id = 2;
            //List<AdminLog> logs = new List<AdminLog>();
            //logs.Add(new AdminLog { LogContent = "11111" });
            //logs.Add(new AdminLog { LogContent = "222" });
            //foreach (var log in model.Logs.ToList())
            //{
            //    model.Logs.Remove(log);
            //    target.Remove(log);
            //    //target.Entry<AdminLog>(log).State = System.Data.EntityState.Deleted;
            //}
            //model.Logs = logs;
            //target.Update(model);
            //Assert.Inconclusive("无法验证不返回值的方法。");

            using (TestUnitOfWork unit = new TestUnitOfWork())
            {                
                AdministratorService service = unit.Get<AdministratorService>();
                Administrator model=new Administrator();
                model.Name="chenjian";
                model.UserName = "admin";
                model.Password = "620389";
                service.Create(model);
                //var xx = service.GetAllPrincipal().First();

                //AdministratorService service2 = unit.Get<AdministratorService>();
                //Administrator model2 = new Administrator();
                //model2.Name = "fff8";
                //model2.Password = "dfsdf";
                //model2.UserName = "eee";
                ////model2.Password = "dfsdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
                //service2.Add(model2);
                unit.Commit();
            }
            Assert.AreEqual(1, 1);
            var cache = new List<List<int>>();
            
        }

        [TestMethod()]
        public void AddTest()
        {
            AddTestHelper<GenericParameterHelper>();
        }
    }

}
